package com.godpaper.as9.commands
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.godpaper.as9.bussiness.delegates.UserDelegate;
	import com.godpaper.as9.events.GetUserInfoEvent;
	import com.godpaper.as9.model.UserModelLocator;
	
	import mx.rpc.IResponder;

	public class GetUserInfoCommand extends CommandBase implements ICommand, IResponder
	{
		private var delegate:UserDelegate;
		private var userModel:UserModelLocator = UserModelLocator.getInstance();
		private var getUserInfoEvent:GetUserInfoEvent;
		public function GetUserInfoCommand()
		{
			super();
			delegate = new UserDelegate(this);
		}
		
		override public function execute(event:CairngormEvent):void
		{
			getUserInfoEvent = GetUserInfoEvent(event);
			delegate.read(userModel.simpleUser.email);
		}
		
		override public function result(data:Object):void
		{
			userModel.userInfo.cno = data.result[0].cno;
			userModel.userInfo.email = data.result[0].email;
			userModel.userInfo.is_admin = Boolean(int(data.result[0].is_admin));
			userModel.userInfo.is_super_admin = Boolean(int(data.result[0].is_super_admin));
			userModel.userInfo.name = data.result[0].name;
			userModel.userInfo.once_belonged = data.result[0].once_belonged;
			userModel.userInfo.password = data.result[0].password;
			userModel.userInfo.registed_time = data.result[0].registed_time;
			userModel.userInfo.sno = data.result[0].sno;
			userModel.userInfo.capcity_upload = data.result[0].capcity_upload;
			userModel.userInfo.capcity_message = data.result[0].capcity_message;
			userModel.userInfo.uploaded = data.result[0].uploaded;
			userModel.userInfo.messaged = data.result[0].messaged;
			trace("[logged in] userModel.userInfo: "+userModel.userInfo);
		}
		
		
	}
}